#include "CCommon.h"
#include "CNode.h"

static CColorManager * colorManager = NULL;

extern "C" void _declspec(dllexport) CreateColorManager()
{
	if(colorManager == NULL)
	{
		colorManager = new CColorManager();
	}
}

extern "C" void _declspec(dllexport) DeleteColorManager()
{
	if(colorManager != NULL)
	{
		delete colorManager;
		colorManager = NULL;
	}
}


extern "C" int _declspec(dllexport) InitColorManager(char uiList[LIST_COUNT_MAX][STRING_LEN_MAX])
{
	
#ifdef DEBUG
	FILE * fp;
	fopen_s(&fp, "uiList.bin", "wb+");
	fwrite(uiList, 100, 1, fp);
	fclose(fp);
#endif

	DeleteColorManager();
	CreateColorManager();

	colorManager->Init(uiList);
	return colorManager->GetYarnCount();
}

extern "C" int _declspec(dllexport) GetColorByYarnNum(int yarnNum)
{
	return (int)colorManager->GetColorByYarnNum(yarnNum);
}